import { createRouter, createWebHistory } from "vue-router";
import { useUserStore } from "../stores/userStore";

const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import("../views/index.vue")
  },
  {
    path: '/indexedDB',
    name: 'indexedDB',
    component: () => import("../views/indexedDB/index.vue")
  },
  {
    path: '/loaddata',
    name: 'loaddata',
    component: () => import("../views/indexedDB/loaddata.vue")
  },
  {
    path: '/dragMan',
    name: 'dragMan',
    component: () => import("../views/dragMan.vue")
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

//router.beforeEach((to, from, next) => {
  // 从持久化存储中同步获取token
  // const token = useUserStore().tokenGetter;

  // if (to.path !== "/login" && !token) {
  //   next("/login");
  // } else {
  //   next();
  // }
// });

export default router;
